package com.example.com.skills_utf8;

import java.net.URI;

import com.dmapp.utils.TIME;
import com.dmapp.utils.Toolkit;
import com.dmapp.utils.Utils1;
import com.dmapp.utils.cHighTimer;

import android.app.ActionBar;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.DownloadListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener {

	MainActivity activity =this;
	
	ActionBar mActionBar ;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		
		
		Button btn1 = (Button)findViewById(R.id.btn1);
		Button btn2 = (Button)findViewById(R.id.btn2);
		Button btn3 = (Button)findViewById(R.id.btn3);
		Button btn4 = (Button)findViewById(R.id.btn4);
		Button btn5 = (Button)findViewById(R.id.btn5);
		Button btn6 = (Button)findViewById(R.id.btn6);
		Button btn7 = (Button)findViewById(R.id.btn7);
		Button btn8 = (Button)findViewById(R.id.btn8);
		Button btn9 = (Button)findViewById(R.id.btn9);
		Button btn10 = (Button)findViewById(R.id.btn10);
		Button btn11 = (Button)findViewById(R.id.btn11);
		Button btn12 = (Button)findViewById(R.id.btn12);
		Button btn13 = (Button)findViewById(R.id.btn13);
		Button btn14 = (Button)findViewById(R.id.btn14);
		Button btn15 = (Button)findViewById(R.id.btn15);
		Button btn16 = (Button)findViewById(R.id.btn16);
		Button btn17 = (Button)findViewById(R.id.btn17);
		Button btn18 = (Button)findViewById(R.id.btn18);
		Button btn19 = (Button)findViewById(R.id.btn19);
		Button btn20 = (Button)findViewById(R.id.btn20);
		Button btn21 = (Button)findViewById(R.id.btn21);
		Button btn22 = (Button)findViewById(R.id.btn22);
		Button btn23 = (Button)findViewById(R.id.btn23);
		
		
		btn1.setOnClickListener(this);
		btn2.setOnClickListener(this);
		btn3.setOnClickListener(this);
		btn4.setOnClickListener(this);
		btn5.setOnClickListener(this);
		btn6.setOnClickListener(this);
		btn7.setOnClickListener(this);
		btn8.setOnClickListener(this);
		btn9.setOnClickListener(this);
		btn10.setOnClickListener(this);
		btn11.setOnClickListener(this);
		btn12.setOnClickListener(this);
		btn13.setOnClickListener(this);
		btn14.setOnClickListener(this);
		btn15.setOnClickListener(this);
		btn16.setOnClickListener(this);
		btn17.setOnClickListener(this);
		btn18.setOnClickListener(this);
		btn19.setOnClickListener(this);
		btn20.setOnClickListener(this);
		btn21.setOnClickListener(this);
		btn22.setOnClickListener(this);
		btn23.setOnClickListener(this);
		
	//	int i =1/0;

		

		
	////////////////////////////////////////////////////
		
		
		
		
		
		
		
	}

	
	
	
	
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		switch(v.getId())
		{
			case R.id.btn1:{
			
				Intent intent = new Intent( activity, ShopsCommentActivity.class);
				startActivity(intent);
				
				
				break;
			}
				
			case R.id.btn2:{
				
				break;
			}
			
			case R.id.btn3:{
				Intent intent = new Intent( activity, EmptyListViewActivity.class);
				startActivity(intent);
				
				break;
			}
			case R.id.btn4:{
				Intent intent = new Intent( activity, LoadMoreListViewActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn5:{
				Intent intent = new Intent( activity, ActionBarTabs.class);
				startActivity(intent);
				
						
				break;
			}
			
			case R.id.btn6:{
				
				Intent intent = new Intent( activity, OpenglActivity.class);
				startActivity(intent);
			
		//		Intent intent = new Intent( activity, TranslucentGLSurfaceViewActivity.class);
		//		startActivity(intent);
				
				
						
				break;
			}
			
			case R.id.btn7:{
				
				Intent intent = new Intent( activity, FragmentStack.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn8:{
				
				Intent intent = new Intent( activity, SupportFragmentStack.class);
				startActivity(intent);
				
				break;
			}

			case R.id.btn9:{
				
				Intent intent = new Intent( activity, FragmentTabs.class);
				startActivity(intent);
				
				break;
			}
	
			case R.id.btn10:{
				
				Intent intent = new Intent( activity, IsRunningActivity.class);
				startActivity(intent);
				
				break;
			}
			case R.id.btn11:{
				
				Intent intent = new Intent( activity, BluetoothServerActivity.class);
				startActivity(intent);
				
				break;
			}
	
			case R.id.btn12:{
				
				Intent intent = new Intent( activity, AnimationActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn13:{
				
				Intent intent = new Intent( activity, ProgressBarActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn14:{
				
				Intent intent = new Intent( activity, ProgressBar1Activity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn15:{
				
				Intent intent = new Intent( activity, MyTabActivity.class);
				startActivity(intent);
				
				break;
			}
			case R.id.btn16:{
				
				Intent intent = new Intent( activity, MyFragmentTabActivity.class);
				startActivity(intent);
				
				break;
			}

			case R.id.btn17:{
				
				Intent intent = new Intent( activity, ImageTextViewActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn18:{
				
				Intent intent = new Intent( activity, UseScrollLayoutActivity.class);
				startActivity(intent);
				
				break;
			}
			
			
			case R.id.btn19:{
				

						new Thread(){
							public void run() {
								
								
								// DownloadManager http://www.cnblogs.com/abob/archive/2009/07/09/1520021.html
								
								
								
								DownloadManager.Request  download = new DownloadManager.Request(
										Uri.parse( "http://img.meilishuo.net/css/images/AndroidShare/Meilishuo_3.6.1_10006.apk" )
										//Uri.parse("http://192.168.0.137/Shenlou_DEMO.exe") 
										);
								
								
								
								/*
								String url ="";
								String title ="";
							      ContentValues values = new ContentValues();
						         values.put(android.provider.D.URI, url);//指定下载地址
						         values.put(Downloads.TITLE,title);//设置下载任务的名称
						         activity.getContentResolver().insert(Downloads.CONTENT_URI, values);//将其插入到DownloadManager的数据库中，数据库会触发修改事件，启动下载任务
						         */
								
								DownloadManager dm = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
								long download_id =dm.enqueue(download);
							
								
								
								final long last_recive = Toolkit.getNetworkSpeed();
							//	for(;;)
								{
									
									new TIME(){

										@Override
										public void fuc() {
											// TODO Auto-generated method stub
											
											// 运行一次 
											long recive =Toolkit.getNetworkSpeed();
											System.out.println(recive-last_recive);
											System.out.println(Utils1.byte2KB(recive-last_recive));
											System.out.println(Utils1.byte2MB(recive-last_recive));
										}
										
									}.time_to_go(10000); //10秒钟的下载量. 得出kb/s.. 300kb/s左右
							
									
									
								
								}
								// 写个自定义的view呢.. 用来不断显示调试信息.
								
							};
							
						}.start();
						
						break;
				}
			
			case R.id.btn20:{
				Intent intent = new Intent(activity, DIYViewActivity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn21:{
				Intent intent = new Intent(activity, NFCActivity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn22:{
				Intent intent = new Intent(activity, TTActivity.class);
				startActivity(intent);
				break;
			}

			case R.id.btn23:{
				Intent intent = new Intent(activity, TT_SimpleActivity.class);
				startActivity(intent);
				break;
			}
			
			
			
	
		}
		
		
	}
	
	


}
